package com.sgb.contract.test;

import android.util.Base64;

import com.alibaba.android.arouter.launcher.ARouter;
import com.sgb.contract.base.ContractSdk;
import com.sgb.contract.base.viewmodel.BaseViewModel;
import com.sgb.contract.test.api.TestNet;
import com.sgb.contract.test.model.LoginEntity;
import com.sgb.contract.utils.ArouterConfigs;
import com.swgk.core.base.api.ICallBack;
import com.swgk.core.base.model.entity.BaseEntity;
import com.swgk.core.dialog.DialogHelper;
import com.swgk.core.util.SharedPreferenceUtil;

/**
 * MainViewModel
 * @author cyj
 */
public class MainViewModel extends BaseViewModel {

    /** 跳转到资金中心MainActivity页面 */
    public void startCapitalModuleMainActivity() {
        // 18780832941 qqq123
        DialogHelper.showProgressDialog(ContractSdk.getInstance().getTopActivity(),"数据加载中").setCanceledOnTouchOutside(true);
        TestNet.getInstance().getTestApi().login("18780832941", Base64.encodeToString("qqq123".getBytes(), Base64.DEFAULT))
                .enqueue(new ICallBack<BaseEntity<LoginEntity>>() {
            @Override
            public void onSuccess(BaseEntity<LoginEntity> data) {
                SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.LOGIN_TOKEN, data.getData().getToken());
                SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.resourcePCToken, data.getData().getResourcePCToken());
            }
        });
    }

    /** 跳转到合同列表页面 */
    public void startContractActivity() {
        ARouter.getInstance().build(ArouterConfigs.AR_CONTRACT).navigation();
    }

    /** 跳转到合同列表页面 */
    public void startContractListActivity() {
        ARouter.getInstance().build(ArouterConfigs.AR_CONTRACT_LIST).navigation();
    }

    /** 跳转到合同列表页面 */
    public void startSignContractActivity() {
        ARouter.getInstance().build(ArouterConfigs.AR_SIGN_CONTRACT).navigation();
    }

    /** 跳转到合同开户页面 */
    public void startOpenAccountActivity() {
        ARouter.getInstance().build(ArouterConfigs.AR_OPEN_ACCOUNT).navigation();
    }
    /** 跳转到已开户合同详情页 */
    public void startAccountDetailActivity() {
        ARouter.getInstance().build(ArouterConfigs.AR_ACCOUNT_DETAIL).navigation();
    }

    /** 跳转到审批申请页面 */
    public void startApprovalActivity() {
        //ARouter.getInstance().build(ArouterConfigs.AR_CONTRACT_APPROVAL).navigation();
    }

}
